package com.my.test.thread.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MyCallable implements Callable<String> {

    public String call() {
        return "hello";
    }


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable my = new MyCallable();

        //1.执行 Callable 方式，需要 FutureTask 实现类的支持，用于接收运算结果。
        FutureTask result = new FutureTask(my);
        new Thread(result).start();

        System.out.println(result.get());
    }
}
